
<style type="text/css">
.config{
	margin:20px;
}
.config table{
	margin-top:20px;
}
.configadd{
	display:none;
	margin:20px;
}
.configadd label{
	display:block;
}
</style>
<script type="text/javascript">
$(document).ready(function(e) {
	try{
		$('.configadd').dialog().each(function(index, element) {
			$(this).dialog('destroy');
		})
	}catch(e){}
	$('.configadd').dialog({
		autoOpen:false,
		modal:true,
		resizable:false,
		title:'添加配置',
		width:400,
		buttons:[
			{text:'确定',click:config_add},
			{ text:"取消",click:function(){$(this).dialog("close");}}
		]
	});
	
});
function config_add(){
	if(checkForm($('.configadd *[name]'))){
		$.ajax({
			url:'system/config!addAction.action',
			type:'POST',
			data:serializeArray($('.configadd *[name]')),
			dataType:"JSON",
			success: function(rs){
				if(rs.code=='0'){
					$('.configadd').dialog('close');
					goPage('system/config!detail.action?id='+rs.id,'#main')
				}else{
					alert(rs.msg);
				}
			}
		});
	}
}
function deleteconfig(_this,id){
	var configname=$(_this).parent().prev().text();
	if(!confirm('确定删除此配置吗？')){
		return;
	}
	$.getJSON('system/config!delete.action',{id:id},function(rs){
		if(rs.code=='1'){
			$(_this).parent().parent().remove();
		}else{
			alert(rs.msg);
		}
	});
}
</script>
<div class="config">
  <button type="button" onClick="$('.configadd').dialog('open')">添加配置</button>
  <div class="configadd">
  	<label>名称：<input type="text" name="name" regx="${check.name}" /></label>
  	<label>描述：<input type="text" name="description" regx="${check.description}" /></label>
  </div>
  <table class="tablestyle1">
    <tr>
      <th>编号</th>
      <th>名称</th>
      <th>描述</th>
      <th>操作</th>
    </tr>
    <#list rslist.config as list>
    <tr>
      <td><a href="javascript:void(0)" onClick="goPage('system/config!detail.action?id=${list._id}','#main')">${list._id}</a></td>
      <td>${list.name}</td>
      <td>${list.description}</td>
      <td class="action"><span onClick="deleteconfig(this,'${list._id}')">删除</span></td>
    </tr>
    </#list>
  </table>
  <#assign page=rslist>
  <#include "../page.html">
</div>